package com.ebs.md.fxmonitor.marketmonitor.config;

/**
 * Revision Author:
 *  $File: //depot/MarketData/fxmonitor/main/src/main/java/com/ebs/md/fxmonitor/marketmonitor/config/AbstarctPriceTopping.java $
 *  $Revision: #1 $
 *  $DateTime: 2012/08/12 10:17:59 $
 *  $Change: 113124 $
 *  $Author: Arik.Sher $
 */

import org.apache.log4j.Logger;

import com.ebs.md.fxmonitor.marketmonitor.MarketMonitorConsts;
import com.ebsdr.fsp.ccc.configuration.IConfiguration;

public abstract class AbstarctPriceTopping implements IPriceToppingConfig, IConfigListener, MarketMonitorConsts
{
    final protected Logger logger = Logger.getLogger(getClass());
	
	private int  distanceThreshold;
	private long submitTimeThreshold;
	private long cancelTimeThreshold;
	private int  numberOfPriceToppings;
	private long timeFrameThreshold;	
		
	
	@Override
	public String getName() {
		return BASIC_CONFIG_NAME;
	}

	@Override
	public void onConfig(IConfiguration configuration) 
	{
		distanceThreshold     = configuration.getInt (getPath() + "/@distance",              EVENT_TOPPING_DISTANCE_THRESHOLD);
		submitTimeThreshold   = configuration.getLong(getPath() + "/@submitTime",            EVENT_TOPPING_SUBMIT_TIME_THRESHOLD);
		cancelTimeThreshold   = configuration.getLong(getPath() + "/@cancelTime",            EVENT_TOPPING_CANCEL_TIME_THRESHOLD);
		numberOfPriceToppings = configuration.getInt (getPath() + "/@numberOfPriceToppings", EVENT_TOPPING_NUMBER_OF_PRICE_TOPPINGS_THRESHOLD);
		timeFrameThreshold    = configuration.getLong(getPath() + "/@timeFrame",             EVENT_TOPPING_TIME_FRAME_THRESHOLD);

		logger.info( getConfigInfo() );
	}

	@Override
	public String getConfigInfo() {
		StringBuilder sb = new StringBuilder(getClass().getSimpleName() + ": ");
		
		sb.append( " distance: "              + distanceThreshold);
		sb.append(", submitTime: "            + submitTimeThreshold);
		sb.append(", cancelTime: "            + cancelTimeThreshold);
		sb.append(", numberOfPriceToppings: " + numberOfPriceToppings);
		sb.append(", timeFrame: "             + timeFrameThreshold);

		return sb.toString();
	}

	public abstract String getPath();
	
	@Override
	public int getDistanceThreshold() {
		return distanceThreshold;
	}

	@Override
	public long getSubmitTimeThreshold() {
		return submitTimeThreshold;
	}

	@Override
	public long getCancelTimeThreshold() {
		return cancelTimeThreshold;
	}

	@Override
	public int getNumberOfPriceToppingsThreshold() {
		return numberOfPriceToppings;
	}

	@Override
	public long getTimeFrameThreshold() {
		return timeFrameThreshold;
	}

}
